﻿var time = 500;
var options = {};
//fir应用发布网站ios应用id
var iosAppId = "5649473c00fc746f27000001";
//fir应用发布网站android应用id
var androidAppId = "5649479400fc746f27000007";
//fir应用发布网站登录用户token
var api_token = "e51f14e1c3d799a23bface5b4eba1267";
//地图服务地址
var mapServerAdrr = "http://222.82.252.248:1030/geoserver/keping/wms";
//测试外网地址
var BaseServerAddr="http://www2.pansoft.com/PanOA/";
//本机地址
//var BaseServerAddr="http://192.168.2.246:8080/OA/";
//OA地址
//var BaseServerAddr="http://192.168.248.161:8089/PanOA/";



var panUtil = {
	/*ajax提交的延时等待效果 */
	ajaxLoding: {
		start: function(waitingmsg, zindex) {
			var zindex2 = 0;
			if (waitingmsg == null) {
				waitingmsg = "正在加载中...";
			}
			if (zindex == null) {
				zindex = 998;
				zindex2 = 1000;
			} else {
				zindex2 = zindex + 10;
			}
			var screenWidth = plus.screen.resolutionWidth;
			var screenHeight = plus.screen.resolutionHeight;
			//判断是否显示蒙层
			var shade = document.createElement('div');
			shade.setAttribute('id', 'shade_over');
			shade.setAttribute('style', 'position: fixed;top: 0;left: 0;right: 0;bottom: 0; background-color: #E8E4E7;opacity:0.5;z-index: ' + zindex + ';');
			var loading = document.createElement('div');
			loading.setAttribute('id', 'loading_layout');
			loading.setAttribute('style', 'position: fixed;top: 40%;left: ' + (screenWidth - 136) / 2 + 'px;width:136px;height: 20%; z-index: ' + zindex2 + ';text-align:center;');

			var viewUrl = plus.webview.currentWebview();
			var imgurl = viewUrl.getURL().split('www')[0] + "www/img/sysicon/loadingn.gif";
			//loading.innerHTML='<img src="'+imgurl+'" style=\"width:100px;height:100px;border-radius:50px\" /><br/>正在加载...';	
			loading.innerHTML = '<img src="' + imgurl + '" style=\"border-radius:50px;width:65px;height:62.5px;\" /><br/><span style="display:block;">' + waitingmsg + '</span>';
			//loading.innerHTML='<div id="p5"></div><br/><span style="display:block;">'+waitingmsg+'</span>';
			document.body.appendChild(shade);
			document.body.appendChild(loading);
			//panUtil.fadeAnimation.fadeIn(shade,"normal");
		},
		stop: function() {
				var shade_over = document.getElementById('shade_over');
				var loading_layout = document.getElementById('loading_layout');
				panUtil.fadeAnimation.fadeOut(shade_over, "normal", 0.5);
				panUtil.fadeAnimation.fadeOut(loading_layout, "normal", 0.5);

				setTimeout(function() {
					var shade_over = document.getElementById('shade_over');
					var loading_layout = document.getElementById('loading_layout');
					if (shade_over != null) {
						shade_over.parentNode.removeChild(shade_over);
					}
					if (loading_layout != null) {
						loading_layout.parentNode.removeChild(loading_layout);
					}
				}, panUtil.fadeAnimation.getSpeed("normal"));
			}
			/* stop: function(){
	    	setTimeout(
	    		function(){
				   var shade_over = document.getElementById('shade_over');
				   var loading_layout = document.getElementById('loading_layout');
				   shade_over.parentNode.removeChild( shade_over );
				    loading_layout.parentNode.removeChild( loading_layout );	   
			    },500
	    	);
	    }*/
	},
	//日期工具
	DateTool: {
		today: function() {
			var myDate = new Date();
			var fullyear = myDate.getFullYear(); //获取完整的年份(4位,1970-????)
			var month = myDate.getMonth() + 1; //获取当前月份(0-11,0代表1月)
			var thisdate = myDate.getDate(); //获取当前日(1-31)
			return fullyear + '/' + month + '/' + thisdate;
		},
		todayBeforeYear: function() {
			var myDate = new Date();
			var fullyear = myDate.getFullYear();
			return fullyear + '/1/1';
		},
		nowDate: function() {
			var date = new Date();
			var month = date.getMonth() + 1;
			var strDate = date.getDate();
			var strHour = date.getHours();
			var strMin = date.getMinutes();
			var strSecond = date.getSeconds();
			if (month >= 1 && month <= 9) {
				month = "0" + month;
			}
			if (strDate >= 0 && strDate <= 9) {
				strDate = "0" + strDate;
			}
			if (strHour >= 0 && strHour <= 9) {
				strHour = "0" + strHour;
			}
			if (strMin >= 0 && strMin <= 9) {
				strMin = "0" + strMin;
			}
			if (strSecond >= 0 && strSecond <= 9) {
				strSecond = "0" + strSecond;
			}
			var currentdate = date.getFullYear() + "" + month + strDate + strHour + "" + strMin + "" + strSecond;
			return currentdate;
		}
	},
	//object转String
	Object2Str: function(obj) {
		var ret = '';
		for (var i in obj) {
			ret += i + ':' + obj[i];
		}
		return ret;
	},
	ReLogin: function() {

		plus.storage.setItem("autoLogin", 'false');
		//获取所有的webview
		var wvs = plus.webview.all();
		//plus.webview.close(wvs[0]);
		plus.webview.open(wvs[0].getURL());

		var wvs2 = plus.webview.all();
		for (var i = 0; i < wvs2.length - 1; i++) {
			plus.webview.close(wvs[i]);
		}
	},
	/*
	 * @firsttime 第一次请求时间
	 * @time      请求时间间隔
	 * @message   显示提示信息
	 * @callback  要执行的回调函数
	 */
	setCloseTime: function(firsttime, time, message, callback) {
		if (first == null || (new Date().getTime() - first > time)) {
			first = new Date().getTime();
			callback();
		} else {
			mui.toast(message);
		}
	},
	/**
	 * 金额格式化，即使将金额转换为包含逗号的
	 * @param {Object} s 传入的float数字
	 * @param {Object} n 希望返回小数点几位
	 */
	fmoney: function(s, n) { //s:传入的float数字 ，n:希望返回小数点几位
		n = n > 0 && n <= 20 ? n : 2;
		s = parseFloat((s + "").replace(/[^\d\.-]/g, "")).toFixed(n) + "";
		var l = s.split(".")[0].split("").reverse(),
			r = s.split(".")[1];
		t = "";
		var value = "";
		for (i = 0; i < l.length; i++) {
			t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? "," : "");
		}
		value = t.split("").reverse().join("") + "." + r;
		return value.replace("-,", "-");
	},
	/**
	 * 将包含逗号的金额转换为不含逗号
	 * @param {Object} s 需要去掉逗号的字符串
	 */
	rmoney: function(s) {
		//如果字符串后边有元,先把元去除掉
		s = s.replace("元", "").replace("万元", "");
		return parseFloat(s.replace(/[^\d\.-]/g, ""));
	},
	/**
	 * 切换按钮颜色，目的是为了解决Android手机点击按钮颜色切换不明显的问题
	 * @param {Object} id 需要修改button按钮的id
	 * @param {Object} selfcolor 按钮本身颜色
	 * @param {Object} chgcolor 点击时要切换到颜色
	 */
	btn_color_chg: function(id, selfcolor, chgcolor) {
		document.getElementById(id).style.backgroundColor = chgcolor;
		setTimeout(function() {
			document.getElementById(id).style.backgroundColor = selfcolor;
		}, 100);
	},
	/**
	 * 显示蒙层
	 */
	showShade: {
		show: function(color, ids) {
			var id = "shade_over";
			if (color == null) {
				color = "#E8E4E7";
			}
			if (ids != null) {
				id = ids;
			}
			var shade = document.createElement('div');
			shade.setAttribute('id', id);
			shade.setAttribute('style', 'position: fixed;top: 0;left: 0;right: 0;bottom: 0; background-color: ' + color + ';opacity:0.5;z-index: 500;');
			document.body.appendChild(shade);
		},
		show2: function(color) {
			if (color == null) {
				color = "#E8E4E7";
			}
			var shade = document.createElement('div');
			shade.setAttribute('id', 'shade_over2');
			shade.setAttribute('style', 'position: fixed;top: 0;left: 0;right: 0;bottom: 0; background-color: ' + color + ';opacity:0.5;z-index: 2050;');
			document.body.appendChild(shade);
		},
		hide: function(ids) {
			var id = "shade_over";
			if (ids != null) {
				id = ids;
			}
			var shade_over = document.getElementById(id);
			if (shade_over != null) {
				shade_over.parentNode.removeChild(shade_over);
			}
		},
		hide2: function() {
			var id = "shade_over2";
			/*if(ids==null||ids==""){
				id = dis;
			}*/
			var shade_over = document.getElementById(id);
			if (shade_over != null) {
				shade_over.parentNode.removeChild(shade_over);
			}
		}
	},
	/**
	 * 动态重排行号
	 * tableid  为表格ID，num 为从第几行开始
	 */
	refreshNum: function(tableid, num) {
		var tab = document.getElementById(tableid);
		var rowlength = tab.rows.length;
		//表示开始数
		var temp = 1;
		for (var i = num; i < rowlength; i++) {
			tab.rows[i].cells[0].innerHTML = temp;
			temp++;
		}
		//循环结束。将temp归为1
		temp = 1;
	},
	/**
	 * 动态调整span标签的宽度，作用于detail
	 * pan_class 为需要修改宽度的 class、pan_width 为相对于左侧的宽度
	 */
	autoWidth: function(pan_class, pan_width) {
		var right_span = document.getElementsByClassName(pan_class);
		var pmu = plus.screen.resolutionWidth - pan_width;
		for (var i = 0; i < right_span.length; i++) {
			right_span[i].style.width = pmu + "px";
		}
	},
	/**
	 * tab切换
	 * @param {Object} num  几个tab页
	 * @param {Object} btn_id tab也中button的id
	 * @param {Object} span_id tab也中span的id
	 */
	tabChange: function(num, btn_id) {
		if (num == 2) { //两个tab页
			var tab_left = document.querySelector("#tab_left");
			var tab_right = document.querySelector("#tab_right");
			if (btn_id == "tab_left") {
				tab_left.classList.remove('mui-btn-outlined');
				tab_right.classList.add('mui-btn-outlined');
				document.getElementById("pan_tab_span_left").style.color = "white";
				document.getElementById("pan_tab_span_right").style.color = "#00baf3";
				//切换div显示
				document.getElementById("item1").style.display = "block";
				document.getElementById("item2").style.display = "none";
			} else if (btn_id == "tab_right") {
				tab_left.classList.add('mui-btn-outlined');
				tab_right.classList.remove('mui-btn-outlined');
				document.getElementById("pan_tab_span_left").style.color = "#00baf3";
				document.getElementById("pan_tab_span_right").style.color = "white";
				//切换div显示
				document.getElementById("item1").style.display = "none";
				document.getElementById("item2").style.display = "block";
			}
		} else { //三个tab页
			var tab_left = document.querySelector("#tab_left");
			var tab_center = document.querySelector("#tab_center");
			var tab_right = document.querySelector("#tab_right");
			if (btn_id == "tab_left") {
				tab_left.classList.remove('mui-btn-outlined');
				tab_center.classList.add('mui-btn-outlined');
				tab_right.classList.add('mui-btn-outlined');
				document.getElementById("pan_tab_span_left").style.color = "white";
				document.getElementById("pan_tab_span_center").style.color = "#00baf3";
				document.getElementById("pan_tab_span_right").style.color = "#00baf3";
				//切换div显示
				document.getElementById("item1").style.display = "block";
				document.getElementById("item2").style.display = "none";
				document.getElementById("item3").style.display = "none";
			} else if (btn_id == "tab_center") {
				tab_left.classList.add('mui-btn-outlined');
				tab_center.classList.remove('mui-btn-outlined');
				tab_right.classList.add('mui-btn-outlined');
				document.getElementById("pan_tab_span_left").style.color = "#00baf3";
				document.getElementById("pan_tab_span_center").style.color = "white";
				document.getElementById("pan_tab_span_right").style.color = "#00baf3";
				//切换div显示
				document.getElementById("item1").style.display = "none";
				document.getElementById("item2").style.display = "block";
				document.getElementById("item3").style.display = "none";
			} else if (btn_id == "tab_right") {
				tab_left.classList.add('mui-btn-outlined');
				tab_center.classList.add('mui-btn-outlined');
				tab_right.classList.remove('mui-btn-outlined');
				document.getElementById("pan_tab_span_left").style.color = "#00baf3";
				document.getElementById("pan_tab_span_center").style.color = "#00baf3";
				document.getElementById("pan_tab_span_right").style.color = "white";
				//切换div显示
				document.getElementById("item1").style.display = "none";
				document.getElementById("item2").style.display = "none";
				document.getElementById("item3").style.display = "block";
			}
		}
	},
	/**
	 * 
	 * pan_class 为需要修改宽度的 class、pan_width 为相对于左侧的宽度
	 */
	autoWidth: function(pan_class, pan_width) {
		var right_span = document.getElementsByClassName(pan_class);
		var pmu = plus.screen.resolutionWidth - pan_width;
		for (var i = 0; i < right_span.length; i++) {
			right_span[i].style.width = pmu + "px";
		}
	},

	fadeAnimation: {
		// 获取速度值
		getSpeed: function(s) {
			//速度值，可随意更改。
			switch (s) {
				case "fast":
					return 200;
				case "normal":
					return 500;
				case "slow":
					return 1000;
				default:
					return s;
			}
		},
		// 设置透明度
		opacity: function(node, opc) {
			if (node.style.opacity != null) {
				node.style.opacity = opc;
			} else { //for IE
				opc *= 100;
				var alpha = node.style.filter.match(RegExp("alpha\\(opacity=\\S+\\);"));
				node.style.filter = node.style.filter.replace(alpha, "");
				node.style.filter += "alpha(opacity=" + opc + ");";
			}
		},
		// 渐显过程
		fadeInStep: function(node, opc, delay) {
			opc += 0.01;
			panUtil.fadeAnimation.opacity(node, opc);
			if (opc >= 1) {
				return true;
			}
			window.setTimeout(function() {
				panUtil.fadeAnimation.fadeInStep(node, opc, delay);
			}, delay);
		},
		// 渐显
		fadeIn: function(node, speed) {
			if (speed == null) {
				speed = "normal";
			}
			speed = panUtil.fadeAnimation.getSpeed(speed);
			var delay = speed / 100;
			var opc = 0;
			panUtil.fadeAnimation.opacity(node, opc);
			node.style.display = "";
			window.setTimeout(function() {
				panUtil.fadeAnimation.fadeInStep(node, opc, delay);
			}, 0);
		},
		// 渐隐
		fadeOut: function(node, speed, opc) {
			if (speed == null) {
				speed = "normal";
			}
			speed = panUtil.fadeAnimation.getSpeed(speed);
			var delay = speed / 100;
			if (opc == null) {
				opc = 1;
			}
			panUtil.fadeAnimation.opacity(node, opc);
			node.style.display = "";
			window.setTimeout(function() {
				panUtil.fadeAnimation.fadeOutStep(node, opc, delay);
			}, 0);
		},
		// 渐隐过程
		fadeOutStep: function(node, opc, delay) {
			opc -= 0.01;
			panUtil.fadeAnimation.opacity(node, opc);
			if (opc <= 0) {
				node.style.display = "none";
				return true;
			}
			window.setTimeout(function() {
				panUtil.fadeAnimation.fadeOutStep(node, opc, delay);
			}, delay);
		}
	},
	//分页加载数据并初始化表 tableId:父类容器id；clear:是否刷新重新加载数据
	loadPageDatas: function(tableId, clear, configs) {
		var $options = $(options);
		if (configs) {
			$options.attr(tableId, {
				configs: configs
			});
		}
		var $table = $($options.attr(tableId));
		if (clear) {
			$("." + tableId + "_div").css({
				"marginLeft": "100px",
				"opacity": "0"
			});
			$("#" + tableId + "_tableLayout table").each(function() {
				$(this).find('tbody').html('');
			});
			$table.attr('loadFlag', true);
			$table.attr('pageFlag', true);
			$table.attr('page', 1);
		}
		if (!$table.attr('loadFlag'))
			return;
		$table.attr('loadFlag', false);
		if (!$table.attr('page')) {
			$table.attr('page', 1);
		}

		var $configs = $($table.attr('configs'));
		var pagesize = Math.ceil($configs.attr('tableHeight') / 30);
		$($configs.attr('data')).attr('pagesize', pagesize);
		var page = $table.attr('page');
		$($configs.attr('data')).attr('page', page);

		panUtil.ajaxLoding.start();
		mui.ajax($configs.attr('url'), {
			data: $configs.attr('data'),
			dataType: 'json', //服务器返回json格式数据
			type: 'post', //HTTP请求类型
			timeout: 30000, //超时时间设置为10秒；
			success: function(data) {
				$table.attr('loadFlag', true);
				panUtil.ajaxLoding.stop();
				if (data.code == '1') {
					var results = $configs.attr('result').split('.');
					var list = data;
					for (var i = 0; i < results.length; i++) {
						list = $(list).attr(results[i]);
					}

					var items = new Array();
					if ($table.attr('pageFlag')) {
						items = list;
					} else {
						for (var i = 0; i < list.length; i++) {
							var flag = true;
							var c = parseInt(pagesize) - 1;
							var ds = $('#' + tableId + '_info').children().toArray().reverse();
							for (var j = 0; j < c; j++) {
								var $this = $(ds[j]);
								if ($this.attr('id') == $(list[i]).attr($configs.attr('dataId'))) {
									flag = false;
									break;
								}
							}
							if (flag) {
								items.push(list[i]);
							}
						}
					}

					if (list && list.length >= pagesize) {
						$table.attr('page', page + 1);
						$table.attr('pageFlag', true);
					} else {
						$table.attr('pageFlag', false);
					}

					//初始化表格数据
					var tab = $('#' + tableId);
					var count = tab.find('tbody tr').length;
					var num = items.length + count;
					$('#' + tableId + '_num').text("(共" + data.counts + "条  已加载" + num + "条)");
					if (items && items.length == 0) {
						$table.attr('loadFlag', false);
						mui.toast('已经没有数据了!');
					}

					var html = '';
					var thead = '';
					for (var i = 0; i < items.length; i++) {
						count = count + 1;
						var rows = $configs.attr('rows');
						var r = 0;
						thead = '<thead><tr>';
						html += "<tr id=\"" + $(items[i]).attr($configs.attr('dataId')) + "\" class=\"pan_table_tr\">";
						for (var prop in rows) {
							thead += '<th>' + rows[prop] + '</th>';
							if (r == 0) {
								html += "<td class='pan_boot_table_td'>" + count + "</td>";
							} else {
								var v = $(items[i]).attr(prop);
								var p = $configs.attr(prop);
								if (p) {
									v = p[v] ? p[v] : '';
								}
								var s = $configs.attr('style');
								var style = s && $(s).attr(prop) ? $(s).attr(prop) : '';
								html += "<td class='pan_boot_table_td' style='" + style + "'>" + v + "</td>";
							}
							r++;
						}
						thead += '</tr></thead>';
						html += "</tr>";
					}

					if (page == 1) {
						var tbody = $('<tbody>');
						tbody.attr('id', tableId + '_info');
						tbody.append(html);
						tab.html('');
						tab.append(thead);
						tab.append(tbody);
						FixTable(tableId, 0, plus.screen.resolutionWidth, $configs.attr('tableHeight'), 1, 0);
					} else {
						$("#" + tableId + "_tableLayout table").each(function() {
							$(this).find('tbody').append(html);
						});
					}

					$(document).ready(function() {
						$('#' + tableId + "_tableData").scroll(function() {
							var $this = $(this);
							viewH = $this.height(); //可见高度  
							contentH = $this.get(0).scrollHeight; //内容高度  
							scrollTop = $this.scrollTop(); //滚动高度  
							//if(contentH - viewH - scrollTop <= 100) { //到达底部100px时,加载新内容
							if (scrollTop / (contentH - viewH) >= 0.95) { //到达底部100px时,加载新内容 
								panUtil.loadPageDatas(tableId, false, null);
							}
						});
					});
				} else if (data.code == "fail_token") {
					mui.toast(data.message);
					setTimeout(function() {
						panUtil.ReLogin();
					}, 1000);
				} else {
					mui.toast(data.message);
				}
				if (clear) {
					$("." + tableId + "_div").animate({
						"marginLeft": "0px",
						"opacity": "1"
					}, 800);
				}
			},
			error: function(xhr, type, errorThrown) {
				$table.attr('loadFlag', true);
				panUtil.ajaxLoding.stop();
			}
		});
	},
	//分页加载数据并初始化列表（家庭档案和家庭成员列表）tableId:父类容器id；clear:是否刷新重新加载数据
	loadPageDataLists: function(tableId, clear, configs) {
		var $options = $(options);
		if (configs) {
			$options.attr(tableId, {
				configs: configs
			});
		}
		var $table = $($options.attr(tableId));
		if (clear) {
			$table.attr('loadFlag', true);
			$table.attr('pageFlag', true);
			$table.attr('page', 1);
		}
		if (!$table.attr('loadFlag'))
			return;
		$table.attr('loadFlag', false);
		if (!$table.attr('page')) {
			$table.attr('page', 1);
		}

		var $configs = $($table.attr('configs'));
		var table = $('#' + tableId);
		var pagesize = Math.ceil(table.height() / 50);
		$($configs.attr('data')).attr('pagesize', pagesize);
		var page = $table.attr('page');
		$($configs.attr('data')).attr('page', page);
		panUtil.ajaxLoding.start();
		mui.ajax($configs.attr('url'), {
			data: $configs.attr('data'),
			dataType: 'json', //服务器返回json格式数据
			type: 'post', //HTTP请求类型
			timeout: 30000, //超时时间设置为10秒；
			success: function(data) {
				var tab = table.find('.mui-scroll');
				$table.attr('loadFlag', true);
				panUtil.ajaxLoding.stop();
				if (data.code == '1') {
					var results = $configs.attr('result').split('.');
					var list = data;
					for (var i = 0; i < results.length; i++) {
						list = $(list).attr(results[i]);
					}
					var items = new Array();
					if ($table.attr('pageFlag')) {
						items = list;
					} else {
						for (var i = 0; i < list.length; i++) {
							var flag = true;
							var c = parseInt(pagesize) - 1;
							var ds = tab.find('ul').children().toArray().reverse();
							for (var j = 0; j < c; j++) {
								var $this = $(ds[j]);
								if ($this.attr('id') == $(list[i]).attr($configs.attr('dataId'))) {
									flag = false;
									break;
								}
							}
							if (flag) {
								items.push(list[i]);
							}
						}
					}

					if (list && list.length >= pagesize) {
						$table.attr('page', page + 1);
						$table.attr('pageFlag', true);
					} else {
						$table.attr('pageFlag', false);
					}

					if (clear)
						tab.html('');
					if (items && items.length == 0) {
						$table.attr('loadFlag', false);
						mui.toast('已经没有数据了!');
					} else {
						var count = tab.find('ul li').length;
						var num = items.length + count;
						$('#' + $configs.attr('allCount')).html(data.counts);
						$('#' + $configs.attr('loadCount')).html(num);
						var listType = $configs.attr('listType');
						var h = '<ul id="pan_table_list" class="mui-table-view mui-table-view-chevron">';
						for (var i = 0; i < items.length; i++) {
							count = count + 1;
							h += '<li id="' + $(items[i]).attr($configs.attr('dataId')) + '" class="mui-table-view-cell" style="padding:5px 15px;">';
							if (listType == 'jtda') {
								var span = '';
								var location = '';
								if (items[i].F_JTPJ == 'ZD') {
									span = '<span style="float:left;border:1px solid #FFA500;border-radius:3px;color:#FFA500;font-size:12px;height:20px;">重点户</span>';
								} else if (items[i].F_JTPJ == 'GK') {
									span = '<span style="float:left;border:1px solid red;border-radius:3px;color:red;font-size:12px;height:20px;">管控户</span>';
								} else if (items[i].F_JTPJ == 'FX') {
									span = '<span style="float:left;border:1px solid green;border-radius:3px;color:green;font-size:12px;height:20px;">放心户</span>';
								} else {
									span = '<span style="float:left;border:1px solid #01aeeb;border-radius:3px;color:#01aeeb;font-size:12px;height:20px;">一般户</span>';
								}
								if (items[i].F_MPHDYH && items[i].F_MPHDYH != '') {
									location = '<img src="../img/list/LocationPin.png" width="10px" height="13px" style="margin-left:5px;"/><span style="margin-left:5px;">' + items[i].F_MPHDYH + '</span>';
								}

								h += '<div style="width:100%;height:45px;">';
								h += '<div style="float:left;width:80%;height:45px;">';
								h += '<div style="float:left;width:190px;height:25px;font-size:15px;color:#477fb4;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"><a class="jtda_hz jthz-default-color" style="text-decoration:none;"><span class="mui-badge mui-badge-success">' + count + '</span>' + items[i].F_HZXM + '</a></div>' + span;
								h += '<div style="width:100%;height:20px;font-size:14px;color:#999999;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">';
								h += '<span style="color:#666666;">村组：' + items[i].F_ZXQ + " 家庭人口：" + items[i].F_JTRK + '</span>' + location;
								h += '</div>';
								h += '</div>';

								h += '<div style="float:right;width:20%;height:45px;">';
								h += '<div style="width:85px;height:40px;float:right;margin-top:5px;">';
								h += '<div class="jtda_cy jtcy-default-color"><img src="../img/list/jtcy@2x.png" width="20px" height="20px" style="margin-top:5px;"/></div>';
								h += '<div class="jtda_czfw czfw-default-color"><img src="../img/list/zufang@2x.png" width="20px" height="20px" style="margin-top:5px;"/></div>';
								h += '</div>';
								h += '</div>';
							} else if (listType == 'jtcy') {
								h += '<div style="width:100%;">';
								h += '<div style="float:left;width:65px;height:65px;"><div style="height:72px;display:table-cell;vertical-align:middle;"><img id="' + items[i].F_GRBH + '_headimg" style="border-radius:50px;" src="../img/photo_moren.jpg" width="60px" height="60px"/></div></div>';
								h += '<div style="float:left;width:225px;height:65px;">';
								h += '<div style="width:100%;height:25px;"><div style="float:left;width:180px;height:22px;font-size:15px;color:#477fb4;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"><span class="mui-badge mui-badge-success">' + count + '</span>' + items[i].F_GRXM + '</div><span style="float:left;border:1px solid #01aeeb;border-radius:3px;color:#01aeeb;font-size:14px;height:18px;">' + items[i].F_JTGX + '</span></div>';
								h += '<div style="width:100%;height:20px;font-size:14px;color:#666666;">性别：' + (items[i].F_SEX == "0" ? '男' : '女') + '</div>';
								h += '<div style="width:100%;height:20px;font-size:14px;color:#666666;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">身份证号：' + items[i].F_SFZH + '</div>';
								h += '</div>';
								h += '</div>';
								loadPersonPic(items[i].F_GRBH);
							} else if (listType == 'jfjl') {
								h += '<div style="width:100%;height:62px;">';
								h += '<div style="width:100%;height:22px;font-size:15px;color:#477fb4;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"><span class="mui-badge mui-badge-success">' + count + '</span>' + items[i].F_JFHZXM + '</div>';
								h += '<div style="width:100%;height:20px;font-size:15px;color:#666666;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">家访时间：' + items[i].F_SJ + '</div>';
								h += '<div style="width:100%;height:20px;font-size:15px;color:#666666;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">责任承包人：' + items[i].F_ZRR + '</div>';
								h += '</div>';
							} else if (listType == 'lfjl') {
								h += '<div style="width:100%;height:62px;">';
								h += '<div style="width:100%;height:22px;font-size:15px;color:#477fb4;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"><span class="mui-badge mui-badge-success">' + count + '</span>' + items[i].F_LFRXM + '</div>';
								h += '<div style="width:100%;height:20px;font-size:15px;color:#666666;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">来访时间：' + items[i].F_SJ + '</div>';
								h += '<div style="width:100%;height:20px;font-size:15px;color:#666666;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">接访人：' + items[i].F_JDR + '</div>';
								h += '</div>';
							} else if (listType == 'bfjl') {
								h += '<div style="width:100%;height:62px;">';
								h += '<div style="width:100%;height:22px;font-size:15px;color:#477fb4;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"><span class="mui-badge mui-badge-success">' + count + '</span>' + items[i].F_BFDX + '</div>';
								h += '<div style="width:100%;height:20px;font-size:15px;color:#666666;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">帮扶时间：' + items[i].F_BFSJ + '</div>';
								h += '<div style="width:100%;height:20px;font-size:15px;color:#666666;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">帮扶人员：' + items[i].F_BFRY + '</div>';
								h += '</div>';
							} else if (listType == 'czfw') {
								h += '<div style="width:100%;height:62px;">';
								h += '<div style="width:100%;height:22px;font-size:15px;color:#477fb4;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"><span class="mui-badge mui-badge-success">' + count + '</span>' + items[i].F_CZRXM + '</div>';
								h += '<div style="width:100%;height:20px;font-size:15px;color:#666666;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">身份证号：' + items[i].F_CZRSFZH + '</div>';
								h += '<div style="width:100%;height:20px;font-size:15px;color:#666666;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">出租起止时间：' + items[i].F_CZQZSJ + '</div>';
								h += '</div>';
							}
							h += '</li>';
						}
						h += '</ul>';
						tab.append(h);
					}

					//阻尼系数
					var deceleration = mui.os.ios ? 0.003 : 0.0009;
					mui('#' + tableId).scroll({
						bounce: false,
						indicators: true, //是否显示滚动条
						deceleration: deceleration
					});
					mui('#' + tableId).pullRefresh();
					$(document).ready(function() {
						table.scroll(function() {
							var w = tab.height();
							var y = tab.offset().top;
							var h = $(this).height();
							if ((Math.abs(y) + h) >= w - 50) {
								panUtil.loadPageDataLists(tableId, false, null);
							}
						});
					});
				} else if (data.code == "fail_token") {
					mui.toast(data.message);
					setTimeout(function() {
						panUtil.ReLogin();
					}, 1000);
				} else {
					mui.toast(data.message);
				}
			},
			error: function(xhr, type, errorThrown) {
				$table.attr('loadFlag', true);
				panUtil.ajaxLoding.stop();
			}
		});
	},
	formatDate:function(str){
		if(str&&str.length>=14){
			if(str.length>14){
				str = str.substring(0,14)
			}
			var a = "";
			var a = panUtil.insert_flg(str,"-",4);
			a = panUtil.insert_flg(a,"-",7);
			a = panUtil.insert_flg(a," ",10);
			a = panUtil.insert_flg(a,":",13);
			a = panUtil.insert_flg(a,":",16);
			return a;
		}else{
			return str;
		}
	},
	insert_flg:function(str,flg,sn){
    var newstr="";
    var tmp1=str.substring(0, sn);
    var tmp2=str.substring(sn);
    newstr =tmp1+flg +tmp2;
    return newstr;
}
}
var arrColor = new Array(5);
arrColor[0] = "background-color:#FFDB64";
arrColor[1] = "background-color:#FF8D8B";
arrColor[2] = "background-color:#1CD199";
arrColor[3] = "background-color:#30A3DF";
arrColor[4] = "background-color:#9D6CE9";
